﻿@using CollegeShop.Infrastructure.Entities.Enum
@{
    ViewBag.Title = "Report";
    Layout = "~/Views/Shared/_Staff.cshtml";
}

<div class="main-content" style="margin-left: 190px;">
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li><i class="icon-home home-icon"></i><a href="/staff/index">管理控制台</a> </li>
            <li class="active">管理首页</li>
        </ul>
        <!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <div class="page-header">
            <h1>
                @{
                    CollegeShop.Infrastructure.Entities.Entity.User user = ViewBag.ManagerTitle;
                    if (user != null && user.SalesUnit != null)
                    {
                        @:@(user.SalesUnit.SalesUnitName)
                    }
                    }<small><i class="icon-double-angle-right"></i> 销售报表
                 </small>
            </h1>
        </div>
        <!-- /.page-header -->
        <div class="row" style="margin-left: 20px;">
            <div class="widget-box" style="padding-bottom:5px;">
				<div class="widget-header">
					<h4><i class="icon-reorder orange"></i>销售统计</h4>
				</div>

				<div class="widget-body">
					<div class="widget-main">
						<form id="from1" method="get" action="/staff/report">
                            <input type="hidden" name="page" id="hidpage" value="@ViewBag.Page" />
                           <div class="row-fluid">
                                <div class="span2">
                                    <label class="span12" style="float: left;padding-top: 5px;text-align: right;">商品分类：</label>
                                </div>
                                <div class="span3">
                                    <select id="sltcategory" name="category">
                                        <option value="0">全部</option>
                                        <option value="1">时尚小吃</option>
                                        <option value="2">充饥食品</option>
                                        <option value="3">营养饮品</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                                <div class="span1">
                                    <label class="span12" style="float: left; padding-top: 5px;text-align: right;">订单时间：</label>
                                </div>
                                <div class="span6">
                                    <select id="slttimespan" name="timespan">
                                        <option value="0">全部</option>
                                        <option value="1">第一季度</option>
                                        <option value="2">第二季度</option>
                                        <option value="3">第三季度</option>
                                        <option value="4">第四季度</option>
                                    </select>
                                </div>
                           </div>
                           <div class="row-fluid">
                                <div class="span2">
                                    <label class="span12" style="float: left;padding-top: 5px;text-align: right;">订单状态：</label>
                                </div>
                                <div class="span3">
                                    <select id="sltstate" name="state">
                                        <option value="0">全部</option>
                                        <option value="3">交易完成</option>
                                        <option value="4">交易取消</option>
                                        <option value="9">其他</option>
                                    </select>
                                </div>
                                <div class="span1">
                                   &nbsp;
                                </div>
                                <div class="span6">
                                    &nbsp;
                                </div>
                           </div>
                           <div class="row-fluid" style="padding-top:15px;">
                                <div class="span2"></div>
                                <div class="span10">
							    <button type="submit" class="btn btn-info btn-sm">
								    <i class="icon-search bigger-110"></i>
								    搜索
							    </button>
                                </div>
                           </div>
						</form>
					</div>
				</div>
			</div>
            <div class="widget-box transparent" id="recent-box">

            <div class="widget-main no-padding" style="min-height:300px;">
                <table class="table table-bordered table-striped">
                    <thead class="thin-border-bottom">
                        <tr>
                            <th width="8%">
                                <i class="icon-caret-right blue"></i>客户
                            </th>
                            <td width="18%">
                                <i class="icon-caret-right blue"></i>配送地址
                            </td>
                            <th>
                                <i class="icon-caret-right blue"></i>购买商品
                            </th>
                            <th width="12%">
                                <i class="icon-caret-right blue"></i>订单状态
                            </th>
                            <th width="15%">
                                <i class="icon-caret-right blue"></i>订单时间
                            </th>
                            <th width="12%">
                                <i class="icon-caret-right blue"></i>价格
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    @{
                        CollegeShop.Infrastructure.Entities.ItemListBox<CollegeShop.Infrastructure.Entities.Entity.Orderdetail> orders = ViewBag.SalesItems;
                        if (orders != null && orders.Data != null && orders.Data.Any())
                        {
                            foreach (var item in orders.Data)
                            {
                            <tr>
                                <td>
                                    @item.OrderInfo.LinkMan
                                </td>
                                <td>
                                    @item.OrderInfo.DeliveryAddress
                                </td>
                                <td>
                                    @item.GoodsName @item.Goods.Standard (@item.Goods.Style)
                                </td>
                                <td>
                                    @switch (item.OrderInfo.State)
                                    {
                                        case OrderState.Cancel:
                                            <i class="icon-off grey"></i> <span class="grey">@OrderState.Cancel.Mapping()</span>
                                                                                        break;
                                        case OrderState.Complete:
                                            <i class="icon-ok green"></i> <span class="green">@OrderState.Complete.Mapping()</span>
                                                                                         break;
                                        case OrderState.Confirm:
                                            <i class="icon-bell orange"></i> <span class="orange">@OrderState.Confirm.Mapping()</span>
                                                                                             break;
                                        case OrderState.Payed:
                                            <i class="icon-bell orange"></i> <span class="orange">@OrderState.Payed.Mapping()</span>
                                                                                             break;
                                    }
                                </td>
                                <td>
                                    @item.OrderInfo.OrderTime.ToString("yyyy-MM-dd HH:mm")
                                </td>
                                <td class="hidden-480">
                                    <b class="green">RMB：@item.GoodsPrice</b>
                                </td>
                            </tr>
                            }
                        }
                        else
                        {
                        <tr>
                            <td colspan="6">
                                暂无订单
                            </td>
                        </tr>
                        }
                        }
                    </tbody>
                </table>
            </div>
           
            </div>

            <!-- /.col -->
            <div class="hr hr32 hr-dotted">
            </div>
            @Html.Raw(orders.PageItemSegment)
        </div>
        <!-- /.row -->
    </div>
    <!-- /.page-content -->
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#tabOrder').trigger('click');
            var category = '@Request.QueryString["category"]';
            category = category.length ==0? 0:category;
            $('#sltcategory').val(category);
            var timespan = '@Request.QueryString["timespan"]';
            timespan = timespan.length ==0?0:timespan;
            $('#slttimespan').val(timespan);
            var state = '@Request.QueryString["state"]';
            state = state.length == 0?0:state;
            $('#sltstate').val(state);
        });
        function changePage(sender) {
            $('#hidpage').val(parseInt($(sender).text(),10)-1);
            $('#from1').submit();
        }
    </script>
}